package com.ycd.Servlet;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @Description 登录展示
 * @Author ycd
 * @Date : 2022/3/16 17:13
 * @Version : 1.0
 */
@WebServlet("/login.h")
public class ShowLoginHtmlServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

        req.setCharacterEncoding("utf-8");
        resp.setCharacterEncoding("utf-8");

        String type=req.getParameter("type");
        String msg="";
        if (type != null) {
            switch (type) {
                case "1":
                    msg = "用户名不存在";
                    break;
                case "2":
                    msg = "密码错误";
                    break;
                case "3":
                    msg = "没有权限访问该页面，请登录后进行访问";
                    break;
                case "4":
                    msg = "注册成功";
                    break;
                case "5":
                    msg = "注册失败";
                    break;
            }
        }


        //session作用域
        req.setAttribute("msg",msg);

        req.getRequestDispatcher("WEB-INF/page/login.jsp").forward(req,resp);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        this.doGet(req, resp);
    }
}
